<!DOCTYPE html  >
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">


<head th:include="/base/common_css('test')">

<body>
<div th:include="/base/common_banner"></div>

<!-- Header ends -->
<!-- Main content starts -->

<div class="content">

    <!-- Sidebar -->
    <!--menu ????-->
    <div th:include="/base/common_menu"></div>
    <!--menu????-->
    <!-- Sidebar ends -->

    <!-- Main bar -->
    <div class="mainbar">

        <!-- Page heading -->
        <div th:include="/base/common_pageHeader"></div>
        <!-- Page heading ends -->


        <div class="matter">
            <div class="container">
                <div class="row">
                    <div class="col-md-12">

                        <div class="widget">

                            <div class="widget-head">
                                <div class="pull-left">用户列表</div>
                                <div class="widget-icons pull-right">
                                    <div class="btn-group">
                                        <button type="button" class="btn btn-primary"
                                                data-toggle="modal"
                                                data-target="#myModal" data-backdrop="static">
                                            <i class="glyphicon glyphicon-repeat">新增</i>
                                        </button>
                                    </div>
                                </div>
                                <div class="clearfix"></div>
                            </div>

                            <div class="widget-content medias">
                                <table border="1" style="table-layout:fixed"
                                       class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>
                            <span class="uni">
                              <input type='checkbox' value='check1'/>全选
                            </span>
                                        </th>
                                        <th>序号</th>
                                        <th>用户名</th>
                                        <th>性别</th>
                                        <th>昵称</th>
                                        <th>手机</th>
                                        <th>QQ</th>
                                        <th>微信</th>
                                        <th>微博</th>
                                        <th>邮箱</th>
                                        <th>注册时间</th>
                                        <th>最后登录时间</th>
                                        <th>总积分</th>
                                        <th>现金帐户</th>
                                        <th>是否会员</th>
                                        <th>会员类型</th>
                                        <th>会员开始日期</th>
                                        <th>会员结束日期</th>
                                        <th>剩余购买次数/总数</th>
                                        <th>是否禁言</th>
                                        <th>设置</th>
                                        <th>操作</th>
                                    </tr>
                                    <!--<tbody >-->

                                    <tr th:each="obj,objStat:${userList.list}">
                                        <th>
                            <span class="uni">
                              <input type='checkbox' value='check1'/>
                            </span>
                                        </th>
                                        <td th:text="${objStat.count}">123</td>
                                        <!--<td th:text="${obj.icon}">123</td>-->
                                        <td th:text="${obj.username}"
                                            style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
                                            2223333333333333333333333
                                        </td>
                                        <td th:text="${obj.sex} ? '男': '女'"></td>
                                        <td th:text="${obj.nickname}"
                                            style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
                                            2223333333333333333333333
                                        </td>
                                        <td th:text="${obj.phone}"
                                            style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
                                            2223333333333333333333333
                                        </td>
                                        <td th:text="${obj.qq}"
                                            style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
                                            2223333333333333333333333
                                        </td>
                                        <td th:text="${obj.webchat}"
                                            style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
                                            2223333333333333333333333
                                        </td>
                                        <td th:text="${obj.weibo}"
                                            style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
                                            2223333333333333333333333
                                        </td>
                                        <td th:text="${obj.email}"
                                            style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
                                            2223333333333333333333333
                                        </td>

                                        <td th:text="${#dates.format(obj.registered,'yyyy-MM-dd')}">123</td>
                                        <td th:text="${#dates.format(obj.lastTime,'yyyy-MM-dd')}">123</td>
                                        <td th:text="${obj.point}">123</td>
                                        <td th:text="${obj.money}"
                                            style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
                                            2223333333333333333333333
                                        </td>
                                        <td th:text="${obj.isMember} ? '是': '否'"></td>
                                        <td th:text="${obj.memType} ? '超级会员': '普通会员'"></td>
                                        <td th:text="${#dates.format(obj.memStartDate,'yyyy-MM-dd')}">123</td>
                                        <td th:text="${#dates.format(obj.memEndDate,'yyyy-MM-dd')}">123</td>
                                        <td th:text="${obj.buySurplus} +'/'+ ${obj.buyCount}">123</td>
                                        <!--<td th:text="${obj.buyCount}">123</td>-->
                                        <td th:text="${obj.noSpeaking}? '是': '否'">123</td>
                                        <td>
                                            <a th:href="@{'/view/updateUserExtJY?userId='+${obj.userId}+'&pageNumber=1&pageSize=10'}"
                                               class="btn btn-danger btn-xs">禁言</a><br><br>
                                            <a th:href="@{'/view/updateUserExtQXJY?userId='+${obj.userId}+'&pageNumber=1&pageSize=10'}"
                                               class="btn btn-success btn-xs">取消禁言</a>
                                        </td>
                                        <td>

                                            <a th:href="@{'/view/toUpdateUser?userId='+${obj.userId}}">修改用户信息</a><br>
                                            <a th:href="@{'/view/toUpdateUserExt?userId='+${obj.userId}}">修改扩展信息</a>
                                        </td>
                                    </tr>

                                </table>
                                <div class="widget-foot">
                                    <div id="page3">
                                        <input type="hidden" id="pageNumber" th:value="${userList.pageNum}">
                                        <input type="hidden" id="pageSize" th:value="${userList.pageSize}">
                                        <input type="hidden" id="totalPage" th:value="${userList.pages}">
                                        <input type="hidden" id="total" th:value="${userList.total}">
                                    </div>
                                </div>

                                <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
                                     aria-labelledby="myModalLabel">
                                    <div class="modal-dialog" role="document">

                                        <div style="position:absolute;width:500px; height:500px; overflow:auto">
                                            <div class="modal-content">

                                                <div class="modal-body">
                                                    <form action="#" method="post"
                                                          enctype="multipart/form-data">
                                                        <div class="form-group">
                                                            <label for="username" class="col-lg-4 control-label"
                                                                   style="width:70px ">用户名</label>
                                                            <input style="width:200px " type="text" name="username"
                                                                   class="form-control"
                                                                   id="username" placeholder="用户名" onblur="cateMove()">
                                                            <p id="msg"></p>
                                                        </div>

                                                        <div class="form-group">
                                                            <label for="userpwd" class="col-lg-4 control-label"
                                                                   style="width:70px ">密码</label>
                                                            <input style="width:200px " type="text" name="userpwd"
                                                                   class="form-control"
                                                                   id="userpwd" placeholder="密码">
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="phone" class="col-lg-4 control-label"
                                                                   style="width:70px ">手机</label>
                                                            <input style="width:200px" type="text" name="phone"
                                                                   class="form-control"
                                                                   id="phone" placeholder="手机">
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="nickname" class="col-lg-4 control-label"
                                                                   style="width:70px ">昵称</label>
                                                            <input style="width:200px " type="text" name="nickname"
                                                                   class="form-control"
                                                                   id="nickname" placeholder="昵称">
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="qq" class="col-lg-4 control-label"
                                                                   style="width:70px ">QQ</label>
                                                            <input style="width:200px " type="text" name="qq"
                                                                   class="form-control"
                                                                   onKeyUp="this.value=this.value.replace(/\D/g,'')"
                                                                   onafterpaste="this.value=this.value.replace(/\D/g,'')"
                                                                   id="qq" placeholder="请输入正确的QQ号">
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="webchat" class="col-lg-4 control-label"
                                                                   style="width:70px ">微信</label>
                                                            <input style="width:200px " type="text" name="webchat"
                                                                   class="form-control"
                                                                   id="webchat" placeholder="微信">
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="weibo" class="col-lg-4 control-label"
                                                                   style="width:70px ">微博</label>
                                                            <input style="width:200px " type="text" name="weibo"
                                                                   class="form-control"
                                                                   id="weibo" placeholder="微博">
                                                        </div>
                                                    </form>
                                                </div>

                                                <div class="modal-footer">
                                                    <button style="margin-left:150px;" type="button"
                                                            class="btn btn-default"
                                                            data-dismiss="modal"><span
                                                            class="glyphicon glyphicon-remove"
                                                            aria-hidden="true"
                                                    ></span>取消
                                                    </button>
                                                    <button style="margin-right:150px;" type="button" id="saveUser"
                                                            class="btn btn-primary"
                                                            data-dismiss="modal">
                                                        <span
                                                                class="glyphicon glyphicon-floppy-disk"
                                                                aria-hidden="true">
                                                        </span>保存
                                                    </button>
                                                </div>

                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>

                    </div>
                </div>
                </form>

            </div>
        </div>
    </div>
</div>
</div>
</div>


<!--footer-->
<div th:include="/base/common_footer"></div>
<!---->
</div>
</div>


<!-- Scroll to top -->
<span class="totop"><a href="#"><i class="icon-chevron-up"></i></a></span>

<!--js????-->
<div th:include="/base/common_js"></div>
<!--js????-->

<!-- Script for this page -->

<script type="text/javascript">

    initPage('page3', '/view/user', {}, false);

    function cateMove() {
        var usernaems = document.getElementById("username").value
        var usernaems = $('#username').val().trim();
        if (usernaems.length == 0) {
            alert("用户名不能为空");
            return false;
        } else {
            $.ajax({
                type: "post",
                url: "/view/judge",
                async: false,
                data: {
                    username: $('#username').val(),
                },
                dataType: 'text',
                success: function (mes) {
                    var result = mes;
                    if (result == 0) {
                        $("#msg").html("用户名可用").css({color: "#ff0011"});
                    } else {
                        // alert("用户名已存在");
                        $("#msg").html("用户名已存在").css({color: "#ff0011"});
                        username.focus();
                    }
                }
            });
        }
    }


    //注册新增按钮事件
    $("#btn_add").click(function () {
        $("#myModalLabel").text("新增");
        $('#myModal').modal();
    });
    //注册修改按钮事件
    $("#btn_edit").click(function () {
        $("#myModalLabel").text("修改");
        $('#myModal').modal();
    });


    $("#saveUser").click(function () {
        var phoneNumber = $('#phone').val().trim();
        var partten = /^1[3,5,8]\d{9}$/;
        if ($('#username').val().trim().length == 0) {
            alert("用户名不能为空");
            return false;
        } else {
            if ($('#userpwd').val().trim().length == 0) {
                alert("密码不能为空");
                return false;
            } else {
                if (!partten.test(phoneNumber)) {
                    alert("请输入正确的手机号");
                    return false;
                } else {
                    $.ajax({
                        type: "post",
                        dataType: "json",
                        url: "/view/saveUsers",
                        data: $("form").serialize(),
                        dataType: "json",
                        success: function (data) {

                            alert("添加成功");
                            location.href = "/view/user?pageNumber=1&pageSize=10";
                        },
                    });
                }
            }

        }
    });


    /* Curve chart ends */

</script>
</body>
</html>
